<?php 
include '../functions.php';

//准确版
try{
	$dsn = "mysql:host=127.0.0.1;dbname=zuoye";
	$pdo = new Pdo($dsn,"root","");
	//设置字符集
	$pdo->query("set names utf8");
	//设置错误属性（抛出异常），就可以被catch接收到
	$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
	//返回对象
	$result = $pdo->query("select * from student");
	//接收数组
	$rows = $result->fetchAll(PDO::FETCH_ASSOC);
	p($rows);
}catch(PDOException $e){
	echo "<h2 style='color:red'>".$e->getMessage()."</h2>";
}



